<template>
  <div class="app-container">
    <el-table @row-click="clickRow" ref="table" highlight-current-row
              :header-cell-style="{background:'#d0cece',color:'#000000',fontWeight:'bold'}"
              height="300" class="fixedTableTwo" v-loading="loading" :data="zxydList">
      <!--      <el-table-column type="selection" width="55" align="center"/>-->
      <el-table-column label="序号" align="center" type="index" :index="indexMethod"/>
      <el-table-column label="订单号" align="center" prop="zxydId"/>
      <el-table-column label="预订人姓名" align="center" prop="ydRXm"/>
      <el-table-column label="房间号" align="center" prop="fjh"/>
      <el-table-column label="联系电话" align="center" prop="lxDh"/>
      <el-table-column label="入住日期" align="center" prop="rzRq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rzRq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="离店日期" align="center" prop="ldRq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ldRq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="总价" align="center" prop="zj"/>
    </el-table>
  </div>
</template>

<script>
import {listZxyd} from "@/api/jdgl/zxyd";

export default {
  name: "WdYy", //我的预约
  data() {
    return {
      loading: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ydRXm: null,
        rzRq: null,
        ldRq: null,
        userId: this.$store.state.user.id,
        deptId: null
      },
      zxydList: [],


    }
  },
  created() {
    this.getList();
  },
  methods: {
    //点击行 获取行
    clickRow(row) {
      this.selectedRow = row; // 更新选中的行
      const table = this.$refs.table;
      const selectedRows = table.selection;

      // 否则取消之前选中的行，并选中当前点击的行
      selectedRows.forEach(selectedRow => {
        table.toggleRowSelection(selectedRow);
      });
      table.toggleRowSelection(row);
    },
    /** 自定义序号 */
    indexMethod(index) {
      let pageNum = this.queryParams.pageNum - 1;
      if ((pageNum !== -1 && pageNum !== 0)) {
        return (index + 1) + (pageNum * this.queryParams.pageSize);
      } else {
        return (index + 1)
      }
    },
    /** 查询在线预订列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      listZxyd(this.queryParams).then(response => {
        this.zxydList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },


  }
}
</script>

<style scoped>

</style>
